﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.SqlClient;
using System.Windows.Forms;
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
using System.Reflection.Emit;


namespace VocabularyTrainer
{
    public partial class Form1 : Form
    {
        int i = 0;
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {

            SqlConnectionStringBuilder scsb = new SqlConnectionStringBuilder();
            scsb.DataSource = "LAPTOP-ICQVNAKK";
            scsb.InitialCatalog = "dictionary";
            scsb.UserID = "mya";
            scsb.Password = "mya570909";
            SqlConnection conn = new SqlConnection(scsb.ToString());

            conn.Open();
            string sqlStr = " SELECT * FROM dictionary1 WHERE num = '" + i + "'";

            SqlCommand comm = new SqlCommand(sqlStr, conn);
            SqlDataReader sdr = comm.ExecuteReader();
            while (sdr.Read())
            {
                if (textBox1.Text == sdr["English"].ToString())
                {
                    label5.Text = "True";
                }
                else
                    label5.Text = "False";
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            i++;
            SqlConnectionStringBuilder scsb = new SqlConnectionStringBuilder();
            scsb.DataSource = "LAPTOP-ICQVNAKK";
            scsb.InitialCatalog = "dictionary";
            scsb.UserID = "mya";
            scsb.Password = "mya570909";
            SqlConnection conn = new SqlConnection(scsb.ToString());

            conn.Open();
            string sqlStr = " SELECT * FROM dictionary1 WHERE num = '" + i + "'";

            SqlCommand comm = new SqlCommand(sqlStr, conn);
            SqlDataReader sdr = comm.ExecuteReader();
            while (sdr.Read())
            {
                label4.Text = sdr["Chinese"].ToString();
            }


        }
    }
}
